package com.heima.common.tess4j;

import net.sourceforge.tess4j.Tesseract;
import net.sourceforge.tess4j.TesseractException;

import java.io.File;

public class Test {
    public static void main(String[] args) throws TesseractException {
        //设置tess4j的核心对象
        Tesseract tesseract = new Tesseract();
        //设置语言库的路径
        tesseract.setDatapath("D:\\develop\\tessdata");
        //设置语言
        tesseract.setLanguage("chi_sim");
        //识别图片
        File file = new File("D:\\test.png");
        String url = tesseract.doOCR(file);
        String ter = url.replaceAll("\\r|\n", "-").replace(" ", "");
        System.out.println(ter);
    }
}
